/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

import G25part.ProxiesLeecher;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JTextArea;

/**
 *
 * @author Felipe
 */
public class ProxyThread extends Thread{
    private String url;
    private JProgressBar pb;
    private JTextArea resultList;
    private String lineSeparator = System.getProperty("line.separator");
    private JLabel numberofProxy;

    /**
     * Constructor
     * @param url
     * @param pb
     * @param resultList
     * @param numberofProxy 
     */
    
    public ProxyThread(String url, JProgressBar pb, JTextArea resultList, JLabel numberofProxy) {
        this.url = url;
        this.pb = pb;
        this.resultList = resultList;
        this.numberofProxy = numberofProxy;
    }
    
   /**
     * Run the thread to download the page and get the proxy.
     */
    @Override
    public void run() {
        pb.setIndeterminate(true);
        ProxiesLeecher pl = new ProxiesLeecher(url);
        pl.getProxies();
        for(String proxy : pl.showProxies())
            resultList.setText(resultList.getText()+proxy+lineSeparator);
        numberofProxy.setText(resultList.getLineCount()+"");
        pb.setIndeterminate(false);
    }
    
    
}
